package be.xios.ti.droodle;

import java.awt.event.*;

/**
 * @author Kris Hermans
 */
public class FillRectangleShapeAction extends ShapeDrawAction {
	private RectangleShape rShape;

	/**
	 * @param panel
	 */
	protected FillRectangleShapeAction(ShapeJPanel panel) {
		super(panel);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see be.hogelimb.ti.droodle.ShapeDrawAction#doClick(java.awt.event.MouseEvent)
	 */
	protected void doClick(MouseEvent e) {
		switch (getClickCount()) {
		case 1:
			shape = new RectangleShape();
			rShape = (RectangleShape) shape;
			rShape.setX(e.getX());
			rShape.setY(e.getY());
			rShape.setColor(panel.getForeground());
			rShape.setSize(panel.getPenSize());
			rShape.setFilled(true);
			break;

		case 2:
			rShape.setX2(e.getX());
			rShape.setY2(e.getY());
			ready();
			setClickCount(0);
			break;

		default:
			System.err.println("niet mogelijk");
		}

	}
}
